layui.use(['jquery', 'layer', 'element', 'upload', 'form', ],function (){
    var $ = layui.jquery;
    var layer = layui.layer;
    var element = layui.element;
    var upload = layui.upload;
    var form = layui.form;
    //留言查询
    window.getFileId=function (file_id){
        sessionStorage.setItem("file_id",file_id);
    }
    var id = sessionStorage.getItem("file_id");


    form.on('submit(MessageBtn)',function (data){
        var remark = document.getElementsByName("remark")[0].value;
        $.post({
            url: '/addMessage',
            data: {
                "fileId": id,
                "remark": remark
            },
            success:function (res){
                if(res === "true"){
                    layer.msg("添加留言成功！",{icon:1});
                    location.replace('/message/'+id);
                } else {
                    layer.msg("添加留言失败！",{icon:2});
                }
            }
        })
        return false;
    })
    $('#returnHome').click(function (){
        window.location.href = "/index";
    })
});



//     getElementById是element单数，
//      getElementsByName是elements复数。